Pavel Jakubec
"2016-09-14"
Psittacula krameri
\[ P(A \mid B)= \frac {P(A )P(B \mid A ))}{P(A)} \]
\[ P(\theta \mid y)= \frac {P(\theta )P(y\mid \theta ))}{P(y)} \]
\( P(y)=\int P(\theta)P(y\mid\theta)d\theta \)
Data = Truth, Parameters ~ Probability distribution
Thomas Bayes (1702 - 1761)
Confidence interval vs. Credible interval
triplot.normal.knownvariance2(theta.data=4, variance.known=4, n=5, prior.theta=8, prior.variance=4)
Confidence interval vs. Credible interval
triplot.normal.knownvariance2(theta.data=4, variance.known=4, n=5, prior.theta=8, prior.variance=1)
Positive cancer test \( \neq \) cancer
# Variables
TP <- 0.9 #True Positive: 90%
FP <- 0.1 #False Positive: 10%
\[ P(cancer \mid positive test)= \frac {P(cancer )P(positive test \mid cancer))}{P(cancer )P(positive test \mid cancer))+P(no cancer)P(no cancer \mid positive test)} \]
prior <- 0.01 #Prior (prevalence of cancer in population): 1%
# Bayesian interpretation of the test
result <- (TP*prior)/(TP*prior+FP*(1-prior))
result*100
[1] 8.333333
Using prior knowledge
Low sample size (rare species, lots of NAs, expensive sampling)
Multiple comparisons (Geldman et al., 2012)
Good way how to speed up science & research (significant results can be disproved)
More meaningful and comprehensive inferences (the only exact way how to draw inferences for generalized mixed models (Bolker et al., 2008)
Priors can disproportionally influence the posterior
Choosing the right/appropriate prior can be challenging
Computation heavy (less problem now)
Garbage in = Garbage out
STORY: We screened Amur Leopard (Panthera pardus orientalis) for presence of dangerous blood parasite. If the true percentage of infected ones is greater then 10% we have to inform authorities and take measures to treat them.
CHALENGE: Amur Leopard is very rare and endangered animal, therefore you should use the smallest sample possible
data <- data #Hidden data
N <- c(5,10,15,20,40) #Sample size
sub <- list() #List for storing data values with different N
tests.freq <- list() #List for storing results of exact binomial test
tests.bayes <- list() #List for storing results of bayesian version of exact binomial test
for (i in 1:5) {
sub[[i]] <- data[1:N[i]]
tests.freq[[i]] <- stats::binom.test (c(length(sub[[i]][sub[[i]]=="1"]), length(sub[[i]][sub[[i]]=="0"])), p=0.1, alternative="greater")
tests.bayes[[i]] <- BayesianFirstAid::bayes.binom.test(c(length(sub[[i]][sub[[i]]=="1"]), length(sub[[i]][sub[[i]]=="0"])), p=0.1, n.iter = 150000)
}